﻿namespace Cuofrisp.Core.ParallelCore.Tools
{
    public static class Int32IndexExtensions
    {
        public static (int, int) As2dIndex(this int index, int radix)
        {
            var b = index % radix;
            index /= radix;

            return (index, b);
        }

        public static (int, int, int) As3dIndex(this int index, int radix)
        {
            var c = index % radix;
            index /= radix;

            var b = index % radix;
            index /= radix;

            return (index, b, c);
        }

        public static (int, int, int, int) As4dIndex(this int index, int radix)
        {
            var d = index % radix;
            index /= radix;

            var c = index % radix;
            index /= radix;

            var b = index % radix;
            index /= radix;

            return (index, b, c, d);
        }
    }
}
